<template>
    <div class="app-container">
        <el-card shadow="never">
            <!-- 条件查询 -->
            <el-form v-show="showSearch" ref="queryForm" :model="queryParams" label-width="120px" @keyup.enter.native="submitSearch" @submit.native.prevent>
                <el-row>
                    <el-col :md="6" :sm="12">
                        <el-form-item label="事件编号" prop="dispute_id.value">
                            <el-input v-model="queryParams.dispute_id.value" placeholder="请输入" clearable />
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :md="6" :sm="12">
                        <el-form-item label="争议状态" prop="status.value">
                            <el-select clearable v-model="queryParams.status.value" placeholder="请选择争议状态">
                                <el-option
                                    v-for="item in type_options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :md="6" :sm="12">
                        <el-form-item label="账户" prop="number.value">
                            <el-select clearable @change="change" v-model="queryParams.number.value" placeholder="请选择">
                                <el-option label="01paypal" value="01paypal" />
                                <el-option label="02paypal" value="02paypal" />
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :md="6" :sm="12">
                        <el-form-item class="ele-text-right" label-width="50px">
                            <el-button type="primary" size="mini" @click="submitSearch" icon="el-icon-search" class="ele-btn-icon">搜索 </el-button>
                            <el-button @click="resetQuery" size="mini" icon="el-icon-refresh">重置</el-button>

                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>

            
            <el-row :gutter="10" class="mb8">
                <!-- <el-col :span="1.5">
                    <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="open" v-hasPermi="api.add">添加</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="api.delete">删除</el-button>
                </el-col> -->
                <!-- <el-col :span="1.5">
                    <el-button type="warning" plain icon="el-icon-download" size="mini" v-loading="exportLoading" @click="handleExport" v-hasPermi="api.export">导出</el-button>
                </el-col> -->
                <right-toolbar :showSearch.sync="showSearch" @queryTable="initIndex" :columns="columns" printId="#quickadmin"></right-toolbar>
            </el-row>

            <el-tabs v-model="activeTab" @tab-click="handleStatus" type="border-card">
                <el-tab-pane v-for="(item, index) in type_options" :key="index" :label="item.label" :name="item.value.toString()">
                    <!-- 列表 -->
                    <qa-table
                        :source="tableData"
                        :columns="columns"
                        :selection="true"
                        :loading="loading"
                        @sortChange="sortChange"
                        @statusChange="statusChange"
                        @selectionChange="selectionChange"
                        id="quickadmin"
                    >

                        <template v-slot:action>
                            <el-table-column fixed="right" label="操作" width="180" align="center">
                                <template slot-scope="scope">
                                    <el-button class="btn-mar" size="mini" type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" v-hasPermi="api.edit">查看</el-button>
                                    <!-- <el-button class="btn-mar" size="mini" type="info" icon="el-icon-tickets" @click="handleDetail(scope.row)" v-hasPermi="api.find">详情</el-button> -->
                                    <!-- <el-button class="btn-mar" size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="api.delete">删除</el-button> -->

                                </template>
                            </el-table-column>
                        </template>
                    </qa-table>
                </el-tab-pane>
            </el-tabs>
            <!-- 分页 -->
            <pagination :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="initIndex" />
        </el-card>

        <!-- 编辑弹窗 -->
        <el-dialog :title="!disabled ? '编辑' : '详情'" :visible="editOpen"  :before-close="beforeClose" destroy-on-close>
            <EditForm ref="editForm" :findFormData="findFormData"  :disabled="disabled" @submitForm="submitForm" :editFormParams="editFormParams" @editFormCancel="beforeClose" />
        </el-dialog>

    </div>
</template>

<script>
import { curdMixin } from '@/mixins/curdMixin'
import EditForm from './EditFormCom'
export default {
    name: 'Curd',
    mixins: [curdMixin],
    components: { EditForm },
    
    data() {
        return {
            // table结构
            columns: [
                {
                    visible: true,
                    label: '事件编号',
                    prop: 'dispute_id',
                },
                {
                    visible: true,
                    label: '原因',
                    prop: 'reason',
                }, 
                {
                    visible: true,
                    label: '状态',
                    prop: 'status_alias',
                },
                {
                    visible: true,
                    label: '金额',
                    prop: 'amount',
                },
                {
                    visible: true,
                    label: '时间',
                    prop: 'createtime',
                },
                // {
                //     visible: true,
                //     label: '平台',
                //     prop: 'type',
                //     width: 80,
                //     component: 'QuickAdminTag',
                //     formatter: (prop, row) => {
                //         return row.type
                //     },
                // },
                {
                    visible: true,
                    label: '账户',
                    prop: 'number',
                    width: 80,
                    component: 'QuickAdminTag',
                    formatter: (prop, row) => {
                        return row.number
                    },
                },
                // {
                //     visible: true,
                //     label: '邮箱',
                //     prop: 'customer_email_address',
                // },
                // {
                //     visible: true,
                //     label: '客户',
                //     prop: 'customer_name',
                // },
                // {
                //     visible: true,
                //     label: '总价',
                //     prop: 'amount',
                // },
                // {
                //     visible: true,
                //     label: '货币',
                //     prop: 'currency',
                // },
                // {
                //     visible: true,
                //     label: '关联状态',
                //     prop: 'update_status',
                // },
            ],
            // 接口地址
            api: {
                index: `/admin/orderdispute/index`,
                find: `/admin/orderdispute/find`,
                add: `/admin/orderdispute/add`,
                edit: `/admin/orderdispute/edit`,
                delete: `/admin/orderdispute/delete`,
                export: `/admin/orderdispute/export`,
                status: `/admin/orderdispute/status`
            },
            editFormParams: {
            },
            pageInfo: {
                sort: 'id',
            },
            primaryKey: 'id',
            // 搜索表单是否展开
            searchExpand: false,
              //是否展示搜索
            showSearch: true,
            // 查询参数
            queryParams: {
                id: { value:undefined, op: '%like%'},
                update_status: { value: undefined, op: '=' },
                status: { value: undefined, op: '=' },
                type: { value: undefined, op: '=' },
                number: { value: undefined, op: '=' },
                dispute_id: { value:undefined, op: '%like%'},
            },
            status: [
                { label: '所有', value: '' },
                { label: '已关联订单', value: 'normal' },
                { label: '未关联订单', value: 'hidden' },
            ],
            activeTab: '',
            type_options: [
                {
                    value: 'WAITING_FOR_SELLER_RESPONSE',
                    label: '需要卖家回复'
                },
                {
                    value: 'UNDER_REVIEW',
                    label: '审查中'
                }, 
                {
                    value: 'WAITING_FOR_BUYER_RESPONSE',
                    label: '需要买家回复'
                }, 
                { label: '所有', value: '' },
                {
                    value: 'RESOLVED',
                    label: '已解决'
                }, {
                    value: 'OPEN',
                    label: '公开'
                }, {
                    value: 'OTHER',
                    label: '其他'
                }
            ],
        }
    },
    created () {
        this.initIndex()
    },
    watch: {
        
    },
    methods: {
        // 案列：当前组件格式化方法
        testFormatter(prop) {
            return prop
        },
        // 订单状态切换查询
        handleStatus(tab) {
            this.queryParams.status.value = tab.name
            this.submitSearch()
        },   
    },
}
</script>
<style lang="scss">
.btn-mar {
    margin: 5px !important;
}
</style>
